package com.erp.util;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;

public class CommonUtils {

	/**
	 * MD5摘要
	 * 
	 * @param source
	 * @return
	 */
	public static String generateMd5(String source) {
		return DigestUtils.md5Hex(source);
	}

	/**
	 * Base64加密
	 * 
	 * @param source
	 * @return
	 */
	public static String encodeBase64(String source) {
		return Base64.encodeBase64String(source.getBytes());
	}

	/**
	 * Base64解密
	 * 
	 * @param source
	 * @return
	 */
	public static String decodeBase64(String base64String) {
		return new String(Base64.decodeBase64(base64String));
	}

}
